package com.bw.zcb.mvp.view.user;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.bw.zcb.R;
import com.bw.zcb.utils.ToastUtils;

public class NameActivity extends AppCompatActivity implements View.OnClickListener {

    private EditText nickName;
    private Button saveBtm;
    private TextView back01;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_name);
        initView();

    }

    private void initView() {
        nickName = (EditText) findViewById(R.id.nick_name);
        saveBtm = (Button) findViewById(R.id.save_btm);
        back01 = (TextView) findViewById(R.id.back01);
        back01.setOnClickListener(this::onClick);
        saveBtm.setOnClickListener(this::onClick);

    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (R.id.back01==id){
            finish();
        }
        if (R.id.save_btm==id) {
            String name = nickName.getText().toString().trim();
            if (name.length() == 0) {
                ToastUtils.showMsg("不可以为空");
            } else {
                Intent intent = new Intent();
                intent.setAction("nickName");
                intent.putExtra("nick_Name", name);
                sendBroadcast(intent);
                finish();
            }
        }
    }
}
